# _*_ coding: utf-8
__author__ = 'hb'
__date__ = '2018/11/21 10:05'
# From组件把用户提交的表单进行一部分预处理，例如长度是否合适，格式是否正确，是否为空，判断之后再执行逻辑
from django import forms
from captcha.fields import CaptchaField


class LoginFrom(forms.Form):
    # 这个字段必须有，没有就报错 required=True
    username = forms.CharField(required=True)
    password = forms.CharField(required=True, min_length=5)


class RegisterForm(forms.Form):
    email = forms.EmailField(required=True)
    password = forms.CharField(required=True, min_length=5)
    captcha = CaptchaField(error_messages={"invalid": "验证码错误"})


class ForgetForm(forms.Form):
    email = forms.EmailField(required=True, error_messages={'required':'用户名不能为空'})
    captcha = CaptchaField(error_messages={"invalid": "验证码错误"})


class ModifyPwdForm(forms.Form):
    password1 = forms.CharField(required=True, min_length=5)
    password2 = forms.CharField(required=True, min_length=5)
